package com.example.sunflowers.viewmodels

import com.example.sunflowers.data.db.PlantAndGardenPlantings
import java.text.SimpleDateFormat
import java.util.Locale

/**
 *
 * @Author： LJH
 * @Time： 2024/1/27
 * @description：
 */
class PlantAndGardenPlantingsViewModel(plants:PlantAndGardenPlantings) {

    companion object{
        private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
    }

    private val plant = checkNotNull(plants.plant)
    private val gardenPlanting = plants.gardenPlantings[0]

    val waterDateString:String = dateFormat.format(gardenPlanting.lastWateringDate.time)

    val wateringInterval
        get() = plant.waterInterval

    val imgUrl
        get() = plant.imageUrl

    val plantName
        get() = plant.name

    val plantDateString:String = dateFormat.format(gardenPlanting.plantDate.time)

    val plantId
        get() = plant.plantId


}